package com.heima.wemedia.controller.v2;


import com.heima.model.admin.dto.NewsAuthDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
public class AdminController {

    @Autowired
    private WmNewsService wmNewsService;

    /**
     * 查询文章详情
     * @param id 文章id
     * @return 返回该id对应的文章详情
     */
    @GetMapping("/one_vo/{id}")
    public ResponseResult adminById(@PathVariable Integer id) {
        return wmNewsService.selectNew(id);
    }

    /**
     * 审核通过
     * @param dto 文章id
     * @return
     */
    @PostMapping("/auth_pass")
    public ResponseResult passTheAudit(@RequestBody NewsAuthDto dto) {
        wmNewsService.passTheAudit(dto);
        return ResponseResult.okResult(200,"审核通过");
    }
}
